import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import { rules} from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
import { getWeekMonthQuarterYear } from '/@/utils';
//列表数据
export const columns: BasicColumn[] = [
   {
    title: '员工姓名',
    align:"center",
    sorter: true,
    dataIndex: 'fullName'
   },
   {
    title: '性别',
    align:"center",
    dataIndex: 'gender_dictText'
   },
   {
    title: '联系电话',
    align:"center",
    dataIndex: 'ontactNumber'
   },
   {
    title: '身份证号',
    align:"center",
    dataIndex: 'idCard'
   },
   {
    title: '身份证正面',
    align:"center",
    dataIndex: 'frontIdCard',
    customRender:render.renderImage,
   },
   {
    title: '身份证反面',
    align:"center",
    dataIndex: 'reverseIdCard',
    customRender:render.renderImage,
   },
   {
    title: '银行卡号',
    align:"center",
    dataIndex: 'bankCardNumber'
   },
   {
    title: '开户行',
    align:"center",
    dataIndex: 'openBank'
   },
   {
    title: '开户行网点',
    align:"center",
    dataIndex: 'openBankBranch'
   },
   {
    title: '银行卡照片',
    align:"center",
    dataIndex: 'bankCardPhoto',
    customRender:render.renderImage,
   },
   {
    title: '基本工资',
    align:"center",
    dataIndex: 'basicSalary'
   },
   {
    title: '出勤工天',
    align:"center",
    dataIndex: 'attendanceDays'
   },
   {
    title: '应发工资',
    align:"center",
    dataIndex: 'salaryPayable'
   },
   {
    title: '扣预支',
    align:"center",
    dataIndex: 'paidWages'
   },
   {
    title: '实发工资',
    align:"center",
    dataIndex: 'netSalary'
   },
   {
    title: '考勤周期',
    align:"center",
    dataIndex: 'attendanceCycle'
   },
   {
    title: '是否离职',
    align:"center",
    sorter: true,
    dataIndex: 'isResign',
    customRender:({text}) => {
       return  render.renderSwitch(text, [{text:'是',value:'Y'},{text:'否',value:'N'}])
     },
   },
   {
    title: '加班工时',
    align:"center",
    dataIndex: 'overtimeHours'
   },
   {
    title: '加班工天',
    align:"center",
    dataIndex: 'overtimeDays'
   },
   {
    title: '出勤工时',
    align:"center",
    dataIndex: 'attendanceHours'
   },
   {
    title: '时薪',
    align:"center",
    dataIndex: 'hourlyWage'
   },
];
//查询数据
export const searchFormSchema: FormSchema[] = [
     {
      label: "创建日期",
      field: "createTime",
      component: 'RangePicker',
      componentProps: {
          valueType: 'Date',
          showTime:true
      },
      //colProps: {span: 6},
	},
	{
      label: "员工姓名",
      field: "fullName",
      component: 'Input',
      //colProps: {span: 6},
 	},
];

//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '员工姓名',
    field: 'fullName',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入员工姓名!'},
          ];
     },
  },
  {
    label: '性别',
    field: 'gender',
    component: 'JDictSelectTag',
    componentProps:{
        dictCode:"oa_gender",
        type: "radio"
     },
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入性别!'},
          ];
     },
  },
  {
    label: '联系电话',
    field: 'ontactNumber',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入联系电话!'},
                 { pattern: /^1[3456789]\d{9}$/, message: '请输入正确的手机号码!'},
          ];
     },
  },
  {
    label: '身份证号',
    field: 'idCard',
    component: 'Input',
  },
  {
    label: '身份证正面',
    field: 'frontIdCard',
     component: 'JImageUpload',
     componentProps:{
        fileMax: 0
      },
  },
  {
    label: '身份证反面',
    field: 'reverseIdCard',
     component: 'JImageUpload',
     componentProps:{
        fileMax: 0
      },
  },
  {
    label: '银行卡号',
    field: 'bankCardNumber',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: false},
                 { pattern: /^-?\d+$/, message: '请输入整数!'},
          ];
     },
  },
  {
    label: '开户行',
    field: 'openBank',
    component: 'Input',
  },
  {
    label: '开户行网点',
    field: 'openBankBranch',
    component: 'Input',
  },
  {
    label: '银行卡照片',
    field: 'bankCardPhoto',
     component: 'JImageUpload',
     componentProps:{
        fileMax: 0
      },
  },
  {
    label: '基本工资',
    field: 'basicSalary',
    component: 'InputNumber',
  },
  {
    label: '出勤工天',
    field: 'attendanceDays',
    component: 'InputNumber',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: false},
                 { pattern: /^-?\d+\.?\d*$/, message: '请输入数字!'},
          ];
     },
  },
  {
    label: '应发工资',
    field: 'salaryPayable',
    component: 'InputNumber',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: false},
                 { pattern: /^(([1-9][0-9]*)|([0]\.\d{0,2}|[1-9][0-9]*\.\d{0,2}))$/, message: '请输入正确的金额!'},
          ];
     },
  },
  {
    label: '扣预支',
    field: 'paidWages',
    component: 'InputNumber',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: false},
                 { pattern: /^(([1-9][0-9]*)|([0]\.\d{0,2}|[1-9][0-9]*\.\d{0,2}))$/, message: '请输入正确的金额!'},
          ];
     },
  },
  {
    label: '实发工资',
    field: 'netSalary',
    component: 'InputNumber',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: false},
                 { pattern: /^(([1-9][0-9]*)|([0]\.\d{0,2}|[1-9][0-9]*\.\d{0,2}))$/, message: '请输入正确的金额!'},
          ];
     },
  },
  {
    label: '考勤周期',
    field: 'attendanceCycle',
    component: 'Input',
  },
  {
    label: '是否离职',
    field: 'isResign',
     component: 'JSwitch',
     componentProps:{
     },
  },
  {
    label: '加班工时',
    field: 'overtimeHours',
    component: 'InputNumber',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: false},
                 { pattern: /^-?\d+\.?\d*$/, message: '请输入数字!'},
          ];
     },
  },
  {
    label: '加班工天',
    field: 'overtimeDays',
    component: 'InputNumber',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: false},
                 { pattern: /^-?\d+\.?\d*$/, message: '请输入数字!'},
          ];
     },
  },
  {
    label: '出勤工时',
    field: 'attendanceHours',
    component: 'InputNumber',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: false},
                 { pattern: /^-?\d+\.?\d*$/, message: '请输入数字!'},
          ];
     },
  },
  {
    label: '时薪',
    field: 'hourlyWage',
    component: 'InputNumber',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: false},
                 { pattern: /^(([1-9][0-9]*)|([0]\.\d{0,2}|[1-9][0-9]*\.\d{0,2}))$/, message: '请输入正确的金额!'},
          ];
     },
  },
	// TODO 主键隐藏字段，目前写死为ID
	{
	  label: '',
	  field: 'id',
	  component: 'Input',
	  show: false
	},
];

//子表列表数据
export const oaOvertimeRecordColumns: BasicColumn[] = [
   {
    title: '员工姓名',
    align:"center",
    dataIndex: 'fullName'
   },
   {
    title: '考勤时间',
    align:"center",
    dataIndex: 'attendanceTime',
    customRender:({text}) =>{
      text = !text ? "" : (text.length > 10 ? text.substr(0,10) : text);
      return text;
    },
   },
   {
    title: '工时',
    align:"center",
    dataIndex: 'workingHours'
   },
   {
    title: '工天',
    align:"center",
    dataIndex: 'workingDay'
   },
   {
    title: '备注',
    align:"center",
    dataIndex: 'remarks'
   },
];
//子表表单数据
export const oaOvertimeRecordFormSchema: FormSchema[] = [
  // TODO 子表隐藏字段，目前写死为ID
  {
    label: '',
    field: 'id',
    component: 'Input',
    show: false
  },
  {
    label: '考勤时间',
    field: 'attendanceTime',
    component: 'DatePicker',
    componentProps: {
      valueFormat: 'YYYY-MM-DD'
    },
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入考勤时间!'},
          ];
     },
  },
  {
    label: '工时',
    field: 'workingHours',
    component: 'InputNumber',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入工时!'},
          ];
     },
  },
  {
    label: '工天',
    field: 'workingDay',
    component: 'InputNumber',
  },
  {
    label: '备注',
    field: 'remarks',
    component: 'InputTextArea',
  },
];
//子表列表数据
export const oaAttendanceRecordColumns: BasicColumn[] = [
   {
    title: '员工姓名',
    align:"center",
    dataIndex: 'fullName'
   },
   {
    title: '考勤时间',
    align:"center",
    dataIndex: 'attendanceTime',
    customRender:({text}) =>{
      text = !text ? "" : (text.length > 10 ? text.substr(0,10) : text);
      return text;
    },
   },
   {
    title: '工时',
    align:"center",
    dataIndex: 'workingHours'
   },
   {
    title: '工天',
    align:"center",
    dataIndex: 'workingDay'
   },
   {
    title: '备注',
    align:"center",
    dataIndex: 'remarks'
   },
];
//子表表单数据
export const oaAttendanceRecordFormSchema: FormSchema[] = [
  // TODO 子表隐藏字段，目前写死为ID
  {
    label: '',
    field: 'id',
    component: 'Input',
    show: false
  },
  {
    label: '考勤时间',
    field: 'attendanceTime',
    component: 'DatePicker',
    componentProps: {
      valueFormat: 'YYYY-MM-DD'
    },
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入考勤时间!'},
          ];
     },
  },
  {
    label: '工时',
    field: 'workingHours',
    component: 'InputNumber',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入工时!'},
          ];
     },
  },
  {
    label: '工天',
    field: 'workingDay',
    component: 'InputNumber',
  },
  {
    label: '备注',
    field: 'remarks',
    component: 'InputTextArea',
  },
];
//子表列表数据
export const oaMonthlyAttendanceColumns: BasicColumn[] = [
   {
    title: '员工姓名',
    align:"center",
    dataIndex: 'fullName'
   },
   {
    title: '年份',
    align:"center",
    dataIndex: 'year'
   },
   {
    title: '1月',
    align:"center",
    dataIndex: 'january'
   },
   {
    title: '2月',
    align:"center",
    dataIndex: 'february'
   },
   {
    title: '3月',
    align:"center",
    dataIndex: 'march'
   },
   {
    title: '4月',
    align:"center",
    dataIndex: 'april'
   },
   {
    title: '5月',
    align:"center",
    dataIndex: 'may'
   },
   {
    title: '6月',
    align:"center",
    dataIndex: 'june'
   },
   {
    title: '7月',
    align:"center",
    dataIndex: 'july'
   },
   {
    title: '8月',
    align:"center",
    dataIndex: 'august'
   },
   {
    title: '9月',
    align:"center",
    dataIndex: 'september'
   },
   {
    title: '10月',
    align:"center",
    dataIndex: 'october'
   },
   {
    title: '11月',
    align:"center",
    dataIndex: 'november'
   },
   {
    title: '12月',
    align:"center",
    dataIndex: 'december'
   },
];
//子表表单数据
export const oaMonthlyAttendanceFormSchema: FormSchema[] = [
  // TODO 子表隐藏字段，目前写死为ID
  {
    label: '',
    field: 'id',
    component: 'Input',
    show: false
  },
  {
    label: '年份',
    field: 'year',
    component: 'Input',
  },
  {
    label: '1月',
    field: 'january',
    component: 'InputNumber',
  },
  {
    label: '2月',
    field: 'february',
    component: 'InputNumber',
  },
  {
    label: '3月',
    field: 'march',
    component: 'InputNumber',
  },
  {
    label: '4月',
    field: 'april',
    component: 'InputNumber',
  },
  {
    label: '5月',
    field: 'may',
    component: 'InputNumber',
  },
  {
    label: '6月',
    field: 'june',
    component: 'InputNumber',
  },
  {
    label: '7月',
    field: 'july',
    component: 'InputNumber',
  },
  {
    label: '8月',
    field: 'august',
    component: 'InputNumber',
  },
  {
    label: '9月',
    field: 'september',
    component: 'InputNumber',
  },
  {
    label: '10月',
    field: 'october',
    component: 'InputNumber',
  },
  {
    label: '11月',
    field: 'november',
    component: 'InputNumber',
  },
  {
    label: '12月',
    field: 'december',
    component: 'InputNumber',
  },
];
//子表列表数据
export const oaMonthlyOvertimeColumns: BasicColumn[] = [
   {
    title: '员工姓名',
    align:"center",
    dataIndex: 'fullName'
   },
   {
    title: '年份',
    align:"center",
    dataIndex: 'year'
   },
   {
    title: '1月',
    align:"center",
    dataIndex: 'january'
   },
   {
    title: '2月',
    align:"center",
    dataIndex: 'february'
   },
   {
    title: '3月',
    align:"center",
    dataIndex: 'march'
   },
   {
    title: '4月',
    align:"center",
    dataIndex: 'april'
   },
   {
    title: '5月',
    align:"center",
    dataIndex: 'may'
   },
   {
    title: '6月',
    align:"center",
    dataIndex: 'june'
   },
   {
    title: '7月',
    align:"center",
    dataIndex: 'july'
   },
   {
    title: '8月',
    align:"center",
    dataIndex: 'august'
   },
   {
    title: '9月',
    align:"center",
    dataIndex: 'september'
   },
   {
    title: '10月',
    align:"center",
    dataIndex: 'october'
   },
   {
    title: '11月',
    align:"center",
    dataIndex: 'november'
   },
   {
    title: '12月',
    align:"center",
    dataIndex: 'december'
   },
];
//子表表单数据
export const oaMonthlyOvertimeFormSchema: FormSchema[] = [
  // TODO 子表隐藏字段，目前写死为ID
  {
    label: '',
    field: 'id',
    component: 'Input',
    show: false
  },
  {
    label: '年份',
    field: 'year',
    component: 'Input',
  },
  {
    label: '1月',
    field: 'january',
    component: 'InputNumber',
  },
  {
    label: '2月',
    field: 'february',
    component: 'InputNumber',
  },
  {
    label: '3月',
    field: 'march',
    component: 'InputNumber',
  },
  {
    label: '4月',
    field: 'april',
    component: 'InputNumber',
  },
  {
    label: '5月',
    field: 'may',
    component: 'InputNumber',
  },
  {
    label: '6月',
    field: 'june',
    component: 'InputNumber',
  },
  {
    label: '7月',
    field: 'july',
    component: 'InputNumber',
  },
  {
    label: '8月',
    field: 'august',
    component: 'InputNumber',
  },
  {
    label: '9月',
    field: 'september',
    component: 'InputNumber',
  },
  {
    label: '10月',
    field: 'october',
    component: 'InputNumber',
  },
  {
    label: '11月',
    field: 'november',
    component: 'InputNumber',
  },
  {
    label: '12月',
    field: 'december',
    component: 'InputNumber',
  },
];
//子表列表数据
export const oaPaidWagesColumns: BasicColumn[] = [
   {
    title: '员工姓名',
    align:"center",
    dataIndex: 'fullName'
   },
   {
    title: '支付时间',
    align:"center",
    dataIndex: 'paymentTime'
   },
   {
    title: '支付金额',
    align:"center",
    dataIndex: 'paymentAmount'
   },
   {
    title: '支付方式',
    align:"center",
    dataIndex: 'paymentMethod_dictText'
   },
   {
    title: '员工签字',
    align:"center",
    dataIndex: 'employeeSignature'
   },
   {
    title: '备注',
    align:"center",
    dataIndex: 'remarks'
   },
];
//子表表单数据
export const oaPaidWagesFormSchema: FormSchema[] = [
  // TODO 子表隐藏字段，目前写死为ID
  {
    label: '',
    field: 'id',
    component: 'Input',
    show: false
  },
  {
    label: '支付时间',
    field: 'paymentTime',
    component: 'DatePicker',
    componentProps: {
       showTime:true,
       valueFormat: 'YYYY-MM-DD HH:mm:ss'
     },
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入支付时间!'},
          ];
     },
  },
  {
    label: '支付金额',
    field: 'paymentAmount',
    component: 'InputNumber',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入支付金额!'},
                 { pattern: /^(([1-9][0-9]*)|([0]\.\d{0,2}|[1-9][0-9]*\.\d{0,2}))$/, message: '请输入正确的金额!'},
          ];
     },
  },
  {
    label: '支付方式',
    field: 'paymentMethod',
    component: 'JDictSelectTag',
    componentProps:{
        dictCode:"oa_payment_method"
     },
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入支付方式!'},
          ];
     },
  },
  {
    label: '备注',
    field: 'remarks',
    component: 'InputTextArea',
  },
];

// 高级查询数据
export const superQuerySchema = {
  fullName: {title: '员工姓名',order: 1,view: 'text', type: 'string',},
  gender: {title: '性别',order: 2,view: 'radio', type: 'string',dictCode: 'oa_gender',},
  ontactNumber: {title: '联系电话',order: 3,view: 'text', type: 'string',},
  idCard: {title: '身份证号',order: 4,view: 'text', type: 'string',},
  frontIdCard: {title: '身份证正面',order: 5,view: 'image', type: 'string',},
  reverseIdCard: {title: '身份证反面',order: 6,view: 'image', type: 'string',},
  bankCardNumber: {title: '银行卡号',order: 7,view: 'text', type: 'string',},
  openBank: {title: '开户行',order: 8,view: 'text', type: 'string',},
  openBankBranch: {title: '开户行网点',order: 9,view: 'text', type: 'string',},
  bankCardPhoto: {title: '银行卡照片',order: 10,view: 'image', type: 'string',},
  basicSalary: {title: '基本工资',order: 11,view: 'number', type: 'number',},
  attendanceDays: {title: '出勤工天',order: 12,view: 'number', type: 'number',},
  salaryPayable: {title: '应发工资',order: 13,view: 'number', type: 'number',},
  paidWages: {title: '扣预支',order: 14,view: 'number', type: 'number',},
  netSalary: {title: '实发工资',order: 15,view: 'number', type: 'number',},
  attendanceCycle: {title: '考勤周期',order: 16,view: 'text', type: 'string',},
  isResign: {title: '是否离职',order: 17,view: 'switch', type: 'string',},
  overtimeHours: {title: '加班工时',order: 18,view: 'number', type: 'number',},
  overtimeDays: {title: '加班工天',order: 19,view: 'number', type: 'number',},
  attendanceHours: {title: '出勤工时',order: 20,view: 'number', type: 'number',},
  hourlyWage: {title: '时薪',order: 21,view: 'number', type: 'number',},
};
